package cn.bonoon.controllers.faq;

import java.util.List;

import cn.bonoon.core.IModuleSelected;
import cn.bonoon.core.plugins.FaqCatalogService;
import cn.bonoon.entities.interacting.FaqCatalogEntity;
import cn.bonoon.kernel.annotations.Ignore;
import cn.bonoon.kernel.annotations.Transform;
import cn.bonoon.kernel.events.DialogEvent;
import cn.bonoon.kernel.support.models.Item;
import cn.bonoon.kernel.support.models.ObjectEditor;
import cn.bonoon.kernel.support.services.IService;
import cn.bonoon.kernel.web.EmbedType;
import cn.bonoon.kernel.web.annotations.components.AsCheckbox;
import cn.bonoon.kernel.web.annotations.components.AsSelector;
import cn.bonoon.kernel.web.annotations.components.AsTextArea;
import cn.bonoon.kernel.web.annotations.form.FormEditor;
import cn.bonoon.kernel.web.annotations.form.InsertCell;
import cn.bonoon.kernel.web.annotations.form.PropertyEditor;
import cn.bonoon.kernel.web.handlers.DialogFormInitializer;
import cn.bonoon.kernel.web.models.DialogModel;

@Transform
@FormEditor(value = 2, width = 250)
@InsertCell(name = "发布到", value = "/sys/release-module.vm", colspan = 1, type = EmbedType.PARSE)
public class FaqCatalogEditor extends ObjectEditor implements FaqCatalogDefine, IModuleSelected, DialogFormInitializer<FaqCatalogEntity> {

	private static final long serialVersionUID = 5113387182946309965L;
	
	@PropertyEditor(value = 0, required = true)
	private int ordinal;
	@PropertyEditor(value = 1, required = true)
	private String name;

	@PropertyEditor(10)
	@AsCheckbox("是")
	private boolean platform;
	@PropertyEditor(11)
	@AsSelector(title = "")
	private int level;

	@AsTextArea
	@PropertyEditor(value = 100, colspan = 1)
	private String remark;

//	@PropertyEditor(value = 2, colspan = 1)
//	@AsTextArea(rows = 6)
//	private String question;
//
//	@PropertyEditor(value = 3, colspan = 1)
//	@AsEditor
//	private String answer;

	@Ignore
	private String[] keys;
//	
//	public String getKey() {
//		return key;
//	}
//
//	public void setKey(String key) {
//		this.key = key;
//	}

	@Override
	public Object init(IService<FaqCatalogEntity> service, DialogModel model,
			DialogEvent event, Long id, Object form) throws Exception {
		FaqCatalogService faqCatalogService = (FaqCatalogService)service;
		List<Item> modules = faqCatalogService.releasePlaform(event, id);
		model.addObject("modules", modules);
		return form;
	}
	
	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

//	public String getQuestion() {
//		return question;
//	}
//
//	public void setQuestion(String question) {
//		this.question = question;
//	}
//
//	public String getAnswer() {
//		return answer;
//	}
//
//	public void setAnswer(String answer) {
//		this.answer = answer;
//	}

	public boolean isPlatform() {
		return platform;
	}

	public void setPlatform(boolean platform) {
		this.platform = platform;
	}

	public int getOrdinal() {
		return ordinal;
	}

	public void setOrdinal(int ordinal) {
		this.ordinal = ordinal;
	}

	public String[] getKeys() {
		return keys;
	}

	public void setKeys(String[] keys) {
		this.keys = keys;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

}
